<template>
	<div class="newsBox">
		<div class="news" v-for="item in records" v-if='records.length'>
			<div class="titleBox">
				<div class="title   mhover">
					<!-- <span class="iconfont" :class="item.icon"></span> -->
					<span class="name  mhover">{{ item.channelName }}</span>
				</div>
				<!-- <span class="jt iconfont icon-a-arrowdown"></span> -->
			</div>
			<a class="block_a" :href="Path + item.children[0]?.url" target="_blank" v-if='item.children[0]'>
				<div class="imgbox">
					<span class="p1 flowHidden">{{ item.children.length > 0 && item.children[0]?.title }}</span>
					<img :src="item.children?.length > 0? getImgPath(item.children[0]?.headImag) : ''" alt="" class="img1 pic_width" />
				</div>
			</a>
			<div class="flex xxwBox">
				<div>
					<a class="block_a" :href="Path + item.children[1]?.url" target="_blank" v-if='item.children[1]'>
						<div class="xxwtw">
							<img :src="item.children.length > 1? getImgPath(item.children[1]?.headImag) : ''" alt="" class="img2 pic_width" />
							<br />
							<span class="p2 mhover">{{ item.children.length > 1 && item.children[1]?.title }}</span>
						</div>

						<div class="rdly">
							<span>{{item.children[1]?.contentSourceName}}</span>
						</div>
					</a>
				</div>
				<a class="block_a" :href="Path + item.children[2]?.url" target="_blank" v-if='item.children[2]'>
					<div style="margin-left:21px ;">
						<div class="xxwtw">
							<img :src="item.children?.length > 2? getImgPath(item.children[2]?.headImag):''" alt="" class="img2 pic_width" />
							<br />
							<span class="p2 mhover">{{ item.children.length > 2? item.children[2].title : '' }}</span>
						</div>
						<div class="rdly">
							<span>{{item.children[2]?.contentSourceName}}</span>
						</div>
					</div>
				</a>
			</div>
		</div>
	</div>
</template>

<script>
export default {
	data() {
		return {
			params: {
				pageSize: 10,
				pageNum: 1
			},
			records: [],
			channelList: [],
			Path: getRootPath(),
		};
	},
	created() {
		this.getChannelList();
	},
	mounted() {},
	methods: {
		setNumber(val){
			let value = val;
			if(value>=1000){
				value = value/1000+'K';
			}else if(value>=10000){
				value = value/1000+'W';
			}
			return value || 0;
		},
		getChannelList() {
			// 获取子栏目
			let param = {
				channelPath:'news',
				//parentId:7367,
				count:6,
			};
			homeApi.HeaderChannellist(param, res=>{
				if(res.code == '00000 00000'){
		       this.channelList = res.data;
					 this.$nextTick(()=>{
						 this.channelList.forEach((item, index) => {
							 console.log(213123, item);
						 	let prs = {
						 		pageSize: 3,
						 		pageNum: 1,
						 		channelPaths: item.channelPath,
						 		isTop: true
						 	};
						 	contentApi.fetchContentOfChannel(prs, contents => {
						 		if (contents.code == '00000 00000') {
						 			let obj = {};
						 			obj = Object.assign({}, item, {
						 				children: contents.data.records
						 			});
						 			this.records.push(obj);
						 		} else {
						 		}
						 	});
						 });
					 })
					 
				}
			})
		},
		getImgPath(url){
			return imgPath(url);
		},
	}
};
</script>

<style>
.newsBox {
  width: 1200px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}
.newsBox .news {
  margin-top: 60px;
}
.newsBox .news .titleBox {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.newsBox .news .titleBox .title {
  cursor: pointer;
  color: #333333;
}
.newsBox .news .titleBox .title .iconfont {
  width: 24px;
  height: 24px;
  font-size: 24px;
  line-height: 24px;
  color: #ff3333;
}
.newsBox .news .titleBox .title .name {
  margin-left: 8px;
  height: 24px;
  font-size: 24px;
  font-family: PingFang SC-Semibold, PingFang SC;
  font-weight: 600;
  line-height: 24px;
}
.newsBox .news .titleBox .jt {
  transform: rotate(-90deg);
  border: 1px solid #666666;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
}
.newsBox .news .titleBox .jt:hover {
  color: #666;
}
.newsBox .news .imgbox {
  width: 373px;
  height: 210px;
  margin-top: 24px;
  position: relative;
	overflow: hidden;
}
.newsBox .news .imgbox .img1 {
  width: 373px;
  height: 210px;
  width: auto;
  height: auto;
  margin: auto;
  object-fit: cover;
  border-radius: 4px;
}
.newsBox .news .imgbox:hover .img1 {
  transform: scale(1.1);
}
.newsBox .news .imgbox .p1 {
     width: 100%;
     height: 76px;
     line-height: 26px;
     display: inline-block;
     position: absolute;
     bottom: 0px;
     padding: 16px;
     font-size: 18px;
     font-family: PingFang SC-Regular, PingFang SC;
     font-weight: 400;
     color: #ffffff;
     background: linear-gradient(360deg, #111111 0%, rgba(17,17,17,0) 100%);
     z-index: 1;
     box-sizing: border-box;
     line-height: 64px;
}
.newsBox .news .xxwBox{
  width: 373px;
  margin-top: 20px;
  display: flex;
  justify-content: flex-start;
}
.newsBox .news .xxwBox .xxwtw{
	overflow: hidden;

}
.newsBox .news .xxwBox .img2 {
  width: 176px;
  height: 98px;
  border-radius: 4px;
}
.newsBox .news .xxwBox  .xxwtw:hover .img2{
	transform: scale(1.1);
}
.newsBox .news .xxwBox .p2 {
  margin-top: 16px;
  width: 176px;
  height: 44px;
  font-size: 14px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: #333333;
  line-height: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}
.newsBox .news .xxwBox .rdly {
  margin-top: 24px;
  height: 12px;
  font-size: 12px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: #999999;
  line-height: 12px;
  display: flex;
  justify-content: space-between;
}
.newsBox .news .xxwBox .rdly .iconfont {
  margin-right: 8px;
}

</style>
